<?PHP

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
    <head>
        <title>Inscription</title>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
        <link rel="STYLESHEET" type="text/css" href="style/header_footer_style.css" />
        <link rel="STYLESHEET" type="text/css" href="style/main_style.css" />
        <link rel="STYLESHEET" type="text/css" href="style/pwdwidget.css" />
        <script type="text/javascript" src="scripts/pwdwidget.js"></script>
        <script type="text/javascript" src="scripts/checkApi.js"></script>
        <script>
			function checkFields(){
				var listValue = ["name", "adresse1", "adresse3", "adresse4", "phone", "email", "username", "thepwddiv", "thepwddiv2", "code_secret"];
				var isgood = checkFieldsEmpty(listValue);
	
				if(!isgood)
					return;

				 var isgood = checkFieldsMdpEquals();
					
				 if(!isgood)
					 return;
	
	 			document.forms["register"].submit();			
			}

			function checkFieldsMdpEquals()
			{
				
				var new_pwd = document.getElementById("thepwddiv").value;
				var new_pwd2 = document.getElementById("thepwddiv2").value;
			
	
				if(new_pwd != new_pwd2)
				{
					alert("Les 2 mots de passe ne correspondent pas");
					return false;
				}
				
			
				return true;
			
			}
		</script>
    </head>
    <body>
        <!-- HEADER -->
        <?php include_once './include/header.php'; ?>
        <!-- MAIN -->
        <div id="main" class='inscription'>
            <!-- CONTENT -->  
            <form id='register' action='./handler/register_treatment.php' method='post' accept-charset='UTF-8'>
            	<?PHP if(isset($_GET["register_error"])){ ?>
					<div class='notify'><span>&nbsp;Inscription &eacute;chou&eacute;e, veuillez v&eacute;rifier que vous avez le bon code secret&nbsp;</span></div>
				<?PHP } else { ?>
					<div class='notify'></div>
				<?PHP } ?>
                <fieldset class='fieldset_section'>
                    <legend>INSCRIPTION</legend>
                    <table>
                        <tr>
                            <td class='label'><label for='name' >Nom*</label></td>
                            <td class='input'><input type='text' name='name' id='name' value='' maxlength="50" /></td>
                        </tr>
                        <tr>
							<td class='label'><label for='adresse1' >Adresse / Rue*</label></td>
							<td class='input'><input type='text' name='adresse1' id='adresse1' maxlength="50" /></td>
                        </tr>
                        <tr>
							<td class='label'><label for='adresse2' >Adresse / Compl&eacute;ment</label></td>
							<td class='input'><input type='text' name='adresse2' id='adresse2' maxlength="50" /></td>
                        </tr>
                        <tr>
                            <td class='label'><label for='adresse3&4' >CP - Ville*</label></td>
							<td class='input'><input type='text' class='cp' name='adresse3' id='adresse3' maxlength="5" />&nbsp;<input type='text' class='ville' name='adresse4' id='adresse4' maxlength="30" /></td>
                        </tr>
                        <tr>
                            <td class='label'><label for='phone' >N&deg; téléphone*</label></td>
                            <td class='input'><input type='text' name='phone' id='phone' value='' maxlength="20" /></td>
                        </tr>
                        <tr>
                            <td class='label'><label for='email' >Email*</label></td>
                            <td class='input'><input type='text' name='email' id='email' value='' maxlength="50" /></td>
                        </tr>
                        <tr>
                            <td class='label'><label for='username' >Login*</label></td>
                            <td class='input'><input type='text' name='username' id='username' value='' maxlength="30" /></td>
                        </tr>
                        <tr>
                            <td class='label'><label for='password' >Mot de passe*</label></td>
                            <td class='input'><input type='password' name='thepwddiv' id='thepwddiv' value='' maxlength="30" /></div></td>
                        </tr>
                        <tr>
                            <td class='label'><label for='password' >Vérifier mot de passe*</label></td>
                            <td class='input'><input type='password' name='thepwddiv2' id='thepwddiv2' value='' maxlength="30" /></div></td>
                        </tr>
                         <tr>
                            <td class='label'><label for='code_secret' >Code secret*</label></td>
                            <td class='input'><input type='text' name='code_secret' id='code_secret' value='' maxlength="30" /></td>
                        </tr>
                    </table>
                    <div class='message'>* champs obligatoires</div>
                </fieldset>
                <div><br/>
					<input type="button" onclick="javascript:checkFields()" name="Submit" value="Valider" />
					<input type="button" name="back_login" value="Annuler" onclick="document.location.href='login.php'" ></input>
               	</div>
            </form>
			<script type='text/javascript'>
				var pwdwidget = new PasswordWidget('thepwddiv','password');
				pwdwidget.MakePWDWidget();
			</script>
        </div>
        <!-- FOOTER -->
        <?php include_once './include/footer.php'; ?>
    </body>
</html>